<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>功能开关</title>
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/weui.css" />
</head>
<style type="text/css">
    body{
        background: #F8F8F8;
    }
    .banne{
        width: 100%;
    }
    @media screen and (max-width: 320px) {
        .banne img{
            width:100%;
            height: 150px;
        }
    }
    @media screen and (min-width: 321px) {
        .banne img{
            width:100%;
            height: 200px;
        }
    }
    .weui-cell_link{
        color: #000;
    }
</style>
<body>
<div class="container" id="container">
  <div class="page panel js_show">
    <div class="weui-panel weui-panel_access" style="margin-top: 0;">
        <div class="weui-panel__ft">
            <div class="weui-cells__title">功能开关</div>
            <form method="post">
                <input type="hidden" name="card_id" id="card_id" value="{$card['card_id']}">
                <input type="hidden" name="openid" id="openid" value="{$info['openid']}">
                <input type="hidden" name="is_dedu_cards" id="is_dedu_cards" value="{$info['is_dedu_cards']}">
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell weui-cell_switch">
                        <div class="weui-cell__bd">卡券抵扣</div>
                        <div class="weui-cell__ft">
                            <input class="weui-switch" type="checkbox" id="btn_dedu_cards" name="is_dedu_cards" {eq name="info.is_dedu_cards" value="1"}checked{else/}{/eq}>
                        </div>
                    </div>
                    <div class="weui-cells__tips">开启除余额支付时自动抵扣该商户代金券、折扣券。</div>
                </div>
                <div class="weui-msg__opr-area">
                    <p class="weui-btn-area">
                        <a href="javascript:;" id="tjxg" class="weui-btn weui-btn_primary">确定</a>
                    </p>
                </div>
            </form>
        </div>
    </div>
  </div>
</div>
</body>
<script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
<script>
    $(function () {
        $("#btn_dedu_cards").bind("click", function () {
            if($("#is_dedu_cards").val()=="1"){
                $("#is_dedu_cards").val("0");
            }else{
                $("#is_dedu_cards").val("1");
            }
        });
    });
    $(document).ready(function() {
        if ($("#is_dedu_cards").val() == "1") {
            $("#btn_dedu_cards").val() == "on";
        } else {
            $("#btn_dedu_cards").val() == "off";
        }
    });
</script>
<script type="text/javascript">
    $('#tjxg').click(function() { 			//按钮 单击
        var card_id = $('#card_id').val();
        var openid = $('#openid').val();
        var is_dedu_cards = $('#is_dedu_cards').val();
        $.ajax({
            url: "{:url('carduser/disetup')}",			//提交事件
            type: "post",						//方式
            async: "false",					//异步
            dataType: "JSON",				//类型
            data: {
                card_id:card_id,
                openid:openid,
                is_dedu_cards:is_dedu_cards,
            },		//表单数据
            success: function(data) {			//接收返回值
                if(data.code == 0){
                    alert(data.message);
                }
                if(data.code == 9001){
                    alert(data.message);
                }
            }
        });
    });
</script>
</html>
